/**
* ValidateUtil.java
* Version 1.0.0
* Created on 2018年11月12日
* 
*/
package com.rulin.asp.business.datacleaning.batchimport;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.rulin.asp.business.datacleaning.entity.QuestionNew;


/**
 * @author yangsy
 * @version 1.0.0
 * @since 
 * 创建时间：2018年11月12日
 * <p>功能描述：
 * <p>邮箱地址：446948434@qq.com
 */
public class ValidateUtil {

	public static QuestionResponse checkExercises(List<QuestionNew> list) {
		QuestionResponse response = new QuestionResponse();
		for (int i = 0; i < list.size(); i++) {
			QuestionNew row = list.get(i);
//			String quesCode = StringUtils.trim(row.getQuesCode());
//			String quesType = StringUtils.trim(row.getQuesType());
//			String stem = row.getStem();
			String question = row.getQuestion();
//			String relationCode = row.getRelationCode();
//			String optionA = row.getOptionA();
//			String optionB = row.getOptionB();
//			String optionC = row.getOptionC();
//			String optionD = row.getOptionD();
			String answer = StringUtils.trim(row.getAnswer());
			
			if(StringUtils.isEmpty(question)) {
				response.setCode(QuestionResponse.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，题目信息不能为空。";
				response.setMessage(message);
				return response;
			}
			if(StringUtils.isEmpty(answer)) {
				response.setCode(QuestionResponse.DATA_NULL_ERROR);
				String message = "第"+(i+2)+"行，答案解析不能为空。";
				response.setMessage(message);
				return response;
			}
		}
		response.setCode(QuestionResponse.SUCCESS);
		String message = "数据校验正常";
		response.setMessage(message);
		return response;
	}
	
}
